package com.black.cat.jvm.rtda;

import com.black.cat.jvm.rtda.heap.methodarea.JMethod;

/**
 * @Author blackcat
 * @create 2021/8/12 15:28
 * @version: 1.0
 * @description:线程
 */
public class JThread {

    //Program Counter 寄存器
    private int pc;

    //虚拟机栈
    private JvmStack stack;


    public JThread(){
        this.stack = new JvmStack(1024);
    }

    public int pc(){
        return this.pc;
    }

    public void setPC(int pc){
        this.pc = pc;
    }

    public void pushFrame(Frame frame){
        this.stack.push(frame);
    }

    public Frame popFrame(){
        return this.stack.pop();
    }

    public Frame currentFrame(){
        return this.stack.top();
    }

    public Frame topFrame(){
        return this.stack.top();
    }

    public Frame newFrame(JMethod method) {
        return new Frame(this, method);
    }

    public boolean isStackEmpty(){
        return this.stack.isEmpty();
    }
}
